<template>
    <div class="PurchaseOrderdetail flex ">
        <el-table class="twidth font" :data="purOrderDetailList" v-loading="poDetailLeading">
            <el-table-column fixed label="PI_Name" prop="PI_name" width="200" />
            <el-table-column label="Model" prop="Model" width="150" />
            <el-table-column label="Price" prop="price" />
            <el-table-column label="Total" prop="Total" />
            <el-table-column label="采购数" prop="dty" />
            <el-table-column label="采购价" width="90">
                <template v-slot="cost">
                    <el-input @input="() => { emits('choosePrice') }" :disabled="!priceState ? true : false"
                        v-model="cost.row.cost" />
                </template>
            </el-table-column>
            <el-table-column label="Proft %" prop="Profit" />
            <el-table-column label="State" prop="State" />
            <el-table-column label="Leading" prop="Leading_name" width="120" />
            <el-table-column label="Brand" prop="Brand_name" width="100" />
            <el-table-column align="center" fixed="right" label="Operation" width="150">
                <!-- <template v-slot="operation">
                    <el-button @click="emits('delPurchaseDetails',operation)"
                    style="width: 60%;background-color:#6193D2;color: #fff;border: none;" type="danger">Delete</el-button>
                </template> -->
                <template v-slot="operation">
                    <el-popconfirm confirm-button-text="Yes" cancel-button-text="No" :icon="InfoFilled" icon-color="#626AEF"
                        title="Are you sure to delete this?" @confirm="() => { emits('delPurchaseDetails', operation) }"
                        @cancel="() => { emits('cancelEvent', 'Cancel delete') }">
                        <template #reference>
                            <el-button style="width: 60%;background-color:#6193D2;color: #fff;border: none;"
                                type="danger">Delete</el-button>
                        </template>
                    </el-popconfirm>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script setup>

const props = defineProps({
    poDetailLeading: Boolean,
    state: Boolean,
    purOrderDetailList: Object,
    priceState: Boolean
})
const emits = defineEmits(['delPurchaseDetails', 'choosePrice', 'cancelEvent'])

</script>

<style lang="less">
.PurchaseOrderdetail {
    border-radius: 10px;
    box-sizing: border-box;
    margin-top: 1.5vh;

    // .el-input__inner {
    //     font-family: 'swis'
    // }

    .el-table .cell {
        padding: 0;
    }

    .twidth {
        width: 100%;
        height: 37vh;
        padding: 10px;
        border-radius: 10px;
    }

    .el-table .cell {
        padding-right: 10px;
    }
}
</style>